import * as Utils from 'utils.js';
/**速云报表api**/
/**
 *连接设置
 */
export function settingUrl(arr, callBack) {
	let url = Utils.getPostIp("/api/Login_ShopList");
	let data = arr;
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object} arr验证是否登陆
 */
export function hasLogin(arr, callBack) {
	let url = Utils.getPostIp("/api/Login_UserList_judge");
	let data = arr;
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object} arr验证是否登陆
 */
export function hasLogins(arr, callBack) {
	let url = "http://qf.mygjp.com/QF_ZL/QFZL/QFZL.Views.Default.ajax/AddAgent";
	let data = arr;
	var responseArr = {};
	Utils.httpGetClient(url, data, "POST", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}修改
 */
export  function Change_Bill(arr,callBack){
	let url = Utils.getPostIp("/api/Change_Bill");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"POST",function(data,state){
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object} arr登陆
 */
export function Login(arr, callBack) {
	let url = Utils.getPostIp("/api/Login_UserList");
	let data = arr;
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}


/**
 * @param {Object}商品分类
 */
export function GoodsTypeList(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_GoodsTypeMessage");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}新增商品分类
 */
export function AddGoodsType(arr, callBack) {
	let url = Utils.getPostIp("/api/Add_GoodsTypeMessage");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "POST", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}删除商品分类
 */
export function DeleteGoodsType(arr, callBack) {
	let url = Utils.getPostIp("/api/Delete_GoodsTypeMessage");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "POST", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}修改商品分类
 */
export function UpdateGoodsType(arr, callBack) {
	let url = Utils.getPostIp("/api/Update_GoodsTypeMessage");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "POST", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}查询采购订单
 */
export function GetCgOrder(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Purchase_Report");
	console.log(url);
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}查询销售订单
 */
export function GetSaleOrder(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Sale_Report");
	console.log(url);
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}获取仓库名称
 */
export function GetStoreMessage(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_StoreMessage");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}


/**
 * @param {Object}查询供应商采购汇总
 */
export function GetSupplierPurchase(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Supplier_Purchase");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}查询客户销售汇总
 */
export function GetCustomSale(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Custom_Sale");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}查询经营历程
 */
export function GetBillProcess(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Bill_Process");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}查询经营历程明细
 */
export function GetBillProcessDetai(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Bill_Process_Detail");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}查询业务草稿
 */
export function GetDraftBill(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Draft_Bill");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}查询业务草稿明细
 */
export function GetDraftBillDetail(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Draft_Bill_Detail");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}查询库存状况表
 */
export function GetInventoryStatus(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Inventory_Status");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}



/**
 * @param {Object}查询库存状况明细
 */
export function GetInventoryStatusDetail(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Inventory_Status_Detail");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}


/**
 * @param {Object}查询销售流水
 */
export function GetPosSalesflow(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Pos_Sales_flow");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}


/**
 * @param {Object}查询收银流水
 */
export function GetCashflow(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Cash_flow");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}查询应收应付
 */
export function GetReceivPay(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Receiv_Pay");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}查询采购入库单
 */
export  function Select_Bill_Master(arr,callBack){
	let url = Utils.getPostIp("/api/Select_Bill_Master");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}删除单据
 */
export  function Delete_Bill(arr,callBack){
	let url = Utils.getPostIp("/api/Delete_Bill");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"POST",function(data,state){
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}查看条目明细
 */
export  function Select_Bill_Detail(arr,callBack){
	let url = Utils.getPostIp("/api/Select_Bill_Detail");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}引用上传单据查询-----采购订单
 */
export  function Check_Select_Bill_Order_Master(arr,callBack){
	let url = Utils.getPostIp("/api/Check_Select_Bill_Order_Master");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}引用上传单据查询-----采购入库单
 */
export  function Check_Select_Bill_Master(arr,callBack){
	let url = Utils.getPostIp("/api/Check_Select_Bill_Master");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}引用上传单据查询 ---明细 -----采购订单
 */
export  function Check_Select_Bill_Order_Detail(arr,callBack){
	let url = Utils.getPostIp("/api/Check_Select_Bill_Order_Detail");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}引用上传单据查询 ---明细 -----采购入库单
 */
export  function Check_Select_Bill_Detail(arr,callBack){
	let url = Utils.getPostIp("/api/Check_Select_Bill_Detail");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}引用上传单据查询  -----配出出库单 配送退回单
 */
export  function Check_ZP_Select_Bill_Master(arr,callBack){
	let url = Utils.getPostIp("/api/Check_ZP_Select_Bill_Master");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
/**
 * @param {Object}引用上传单据查询  --------商品明细-------配出出库单 配送退回单
 */
export  function Check_ZP_Select_Bill_Detail(arr,callBack){
	let url = Utils.getPostIp("/api/Check_ZP_Select_Bill_Detail");
	let data =  Utils.getData(arr);
	var responseArr =  {};
	Utils.httpGetClient(url,data,"GET",function(data,state){
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}查询销售毛利汇总
 */

export function GetSaleProfitSum(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Sale_Profit_Sum");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}



/**
 * @param {Object}查询业务员采购
 */
export function GetEmpPurchase(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Emp_Purchase");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}查询业务员销售
 */
export function GetEmpSale(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Emp_Sale");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}出入库明细状况报表
 */
export function GetInOutDetails(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_InOut_Details");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}销售毛利综合报表
 */

export function GetSaleProfit(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_Sale_Profit");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

//保存单据
export function Add_Bill(arr,callBack){
	let url = Utils.getPostIp("/api/Add_Bill");
	var responseArr =  {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url,data,"POST",function(data,state){
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}
//获取单号
export function NewOrderNo(arr,callBack){
	let url = Utils.getPostIp("/api/NewOrderNo");
	var responseArr =  {};
	let data = Utils.getData(arr);
	Utils.httpGetClient(url,data,"POST",function(data,state){
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}查询商品档案
 */
export function GetGoodsMessage(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_GoodsMessage");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}获取员工档案
 */
export function GetOperatorMessage(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_OperatorMessage");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}查詢往来单位
 * 
 * */
export function GetClientMessage(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_ClientMessage");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}


/**
 * @param {Object}商品单位
 */
export function Get_GoodsUnitMessage(arr, callBack) {
	let url = Utils.getPostIp("/api/Get_UnitMessage");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "GET", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}新增商品单位
 */
export function Add_UnitMessage(arr, callBack) {
	let url = Utils.getPostIp("/api/Add_UnitMessage");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "POST", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}修改商品单位
 */
export function Update_UnitMessage(arr, callBack) {
	let url = Utils.getPostIp("/api/Update_UnitMessage");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "POST", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}

/**
 * @param {Object}删除商品分类
 */
export function Delete_UnitMessage(arr, callBack) {
	let url = Utils.getPostIp("/api/Delete_UnitMessage");
	let data = Utils.getData(arr);
	var responseArr = {};
	Utils.httpGetClient(url, data, "POST", function(data, state) {
		console.log(data);
		responseArr.data = data.data;
		responseArr.state = state;
		callBack(responseArr);
	});
}





//图片路径处理
export function setImageUrl(GoodImagePath) {
	//ip
	var ip = uni.getStorageSync("ip");
	//端口
	var ipPost = uni.getStorageSync("ipPost");

	if (GoodImagePath == "") {
		return '/static/default1.jpg';
	} else {
		let path = "http://" + ip;
		if (ipPost != "") {
			path += ":" + ipPost;
		}
		console.log(path + "/picture" + GoodImagePath);
		return path + "/picture" + GoodImagePath;
	}
}


//提示框
export function showTip(msg) {
	uni.showToast({
		position: 'bottom',
		title: msg,
		duration: 1000,
		style: "z-index:9999",
	});
};
//确认框
export function showConfirm(msg, sureClick) {
	uni.showModal({
		title: '提示',
		content: msg,
		success: function(res) {
			if (res.confirm) {
				sureClick(true);
			} else if (res.cancel) {
				sureClick(false);
			}
		}
	});
}
//保留两位小数
export function setTwoFloat(num) {
	return Math.round(num * 100) / 100;
}
